<template>
    <div class="box">
        <JsContentTitle :pageTitle="state.pageTitle" :buttonData="state.buttonData"></JsContentTitle>
        <div class="contentView">
            <JsTable :total="state.totalCount" :dataSource="state.dataSource"
                :columns="state.columns" :refresh="state.refresh">
            </JsTable>
        </div>
    </div>
  </template>
  
  <script setup lang="ts">
  import { onMounted } from "vue"
  import { ref } from "vue"
  import { log } from '@/api/log'
  
  // 查询
  const search = () => {
    log({}).then((res: any) => {
        state.value.dataSource = res.data.data
        state.value.totalCount = res.data.total
    })
  }
  
  const state = ref({
    totalCount: 0,
    refresh: 0,
    pageTitle: '借阅日志',
    columns: {
        props: [
            {
                name: '开始',
                key: 'begin',
            },
            {
                name: '延迟',
                key: 'latency',
            },
            {
                name: '方法',
                key: 'method'
            },
            {
                name: '路径',
                key: 'path'
            },
            {
                name: '状态',
                key: 'status',
            },
            {
                name: '用户名称',
                key: 'username',
            }
        ],
    },
    dataSource: [],
  } as any)
  
  onMounted(() => {
    search()
  })
  </script>
  
  <style lang="scss" scoped>
  *::-webkit-scrollbar {
    display: none;
    width: 10px;
  }
  
  .box {
    display: flex;
    width: 100%;
    height: 100%;
    flex-direction: column;
  
    .contentView {
        background-color: white;
        border-radius: 5px;
        height: calc(100vh - 144px);
        padding: 10px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
  }
  </style>